import { api } from '../../api/index';
const qqmap = require('../../qqmap-wx-jssdk1.2/qqmap-wx-jssdk.js');

// TODO 下面的key要改成服务端可以控制
export const mapInstance = new qqmap({
  key: '3VFBZ-ZLG6W-BCCRD-YDTL7-2UOMZ-M5FDU',
});

const app = getApp();

Page({
    data: {
      page: 'location'
    },
    onLoad(option) {
      // wx.startLocationUpdate({
      //   type: 'gcj02',
      //   success: res => {
      //     console.log(res)
      //   }
      // })
      // wx.openLocation({})

      wx.getLocation({
        type: 'gcj02',
        success: res => {
          console.log(res)
          // wx.chooseLocation({
          //   latitude: res.latitude,
          //   longitude: res.longitude,
          //   success: res => {
          //     console.log(res)
          //   }
          // })
  
          mapInstance.reverseGeocoder({
            location: {
              latitude: res.latitude,
              longitude: res.longitude,
            },
            success: function (geo) {
              console.log("地理位置信息", geo);
            },
            fail: function (t) {
              console.error(t);
            },
            complete: function (t) {
              console.log(t);
            },
          });
        }
      })
    },
});
